package chapter13;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author : DuJiabao
 * @Date : 2021/2/24 15:20
 * @Project : thinking_in_java
 * @File : null.java
 * @Desc :
 */
public class Finding {
  public static void main(String[] args) {
    Pattern compile = Pattern.compile("\\w+");  // 所有单词
    Matcher m = compile.matcher("Evening is full of the linnet's wings");
    while (m.find()) { // 逐个查找，直到找不到匹配的了
      System.out.print(m.group() + " ");
    }
    System.out.println();
    int i = 0;
    while (m.find(i)) {   // 频繁重新设置查找开始点
      System.out.print(m.group() + " ");
      i++;
    }
  }
}
